/**
 * @file   1077.cpp
 * @author Shuang Hu <hsmath@ubuntu>
 * @date   Sat Apr 10 22:05:15 2021
 * 
 * @brief  PAT Problem 1077:Find the longest common string!
 * 
 * 
 */

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int N;
    string coarse[110];
    cin>>N;
    getchar();
    for(int i=0;i<N;i++){
	getline(cin,coarse[i]);
	reverse(coarse[i].begin(),coarse[i].end());
    }
    string result="";//Start from empty string
    int flag=1;
    for(int i=0;i<coarse[0].length();i++){
	char cmp=coarse[0][i];
	for(int j=0;j<N;j++){
	    if(coarse[j][i]!=cmp){
		flag=0;
	    }
	}
	if(flag==0){
	    break;
	}else{
	    result=result+cmp;
	}
    }
    if(result.length()==0){
	cout<<"nai"<<endl;
    }
    else{
    reverse(result.begin(),result.end());
    cout<<result<<endl;
    }
}
